package com.dao.impl;

import com.dao.ChausesDao;
import com.dto.Chauses;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Repository;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.util.Iterator;
import java.util.List;

/**
 * Created by hxw on 2017-6-5.
 */
@Repository("chausesDaoImpl")
public class ChausesDaoImpl implements ChausesDao {

    @Resource(name = "sessionFactory")
    SessionFactory sf;


    public List<Chauses> getRecordList() {
        Session session=sf.openSession();
        String sql=" from Chauses";
        Query query=session.createQuery(sql);
        List<Chauses> recordList=query.list();

        return recordList;
    }


    @Override
    public String saveChauses(Chauses chauses) {
        Session session=sf.openSession();
        session.save(chauses);
        return "success";
    }
}
